<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加减计数器</title>
    <style>
        .counter-container {
            display: flex;
            align-items: center;
            justify-content: center;
            margin-top: 50px;
        }
        .counter-button {
            width: 50px;
            height: 50px;
            font-size: 20px;
            cursor: pointer;
            user-select: none;
        }
        .counter-value {
            width: 50px;
            text-align: center;
            margin: 0 10px;
            font-size: 20px;
        }
    </style>
</head>
<body>
    <div class="counter-container">
        <button class="counter-button" onclick="decreaseCounter()">减</button>
        <div class="counter-value" id="counterValue">0</div>
        <button class="counter-button" onclick="increaseCounter()">加</button>
    </div>

    <script>
        let counterValue = 0;

        function increaseCounter() {
            if (counterValue < 10) {
                counterValue++;
                document.getElementById('counterValue').textContent = counterValue;
            } else {
                alert('已经到顶了，无法再加了');
            }
        }

        function decreaseCounter() {
            if (counterValue > 0) {
                counterValue--;
                document.getElementById('counterValue').textContent = counterValue;
            } else {
                alert('已经到底了，无法再减了');
            }
        }
    </script>
</body>
</html>